package com.ie.controller.admin;

import com.ie.common.http.ResponseResult;
import com.ie.common.security.anno.AuthIgnore;
import com.ie.entity.GoodsTypeEntity;
import com.ie.mapper.admin.GoodsTypeMapper;
import com.ie.service.admin.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author S2
 */
@RestController
@RequestMapping("/api/admin/type")
public class GoodsTypeController {
    @Autowired
    private GoodsTypeService goodsTypeService;

    @AuthIgnore
    @PostMapping("/getAllGoodsType")
    public ResponseResult<List<GoodsTypeEntity>> getAllGoodsType() {
        List<GoodsTypeEntity> list = goodsTypeService.list();
        return ResponseResult.getSuccessResult(list);
    }

    @AuthIgnore
    @PostMapping("/getGoodsType")
    public ResponseResult<Map<String, Object>> getGoodsType(@RequestBody GoodsTypeEntity goodsTypeEntity) {
        return goodsTypeService.getGoodsType(goodsTypeEntity);
    }

    @AuthIgnore
    @PostMapping("/add")
    public ResponseResult<Map<String, Object>> addGoodsType(@RequestBody GoodsTypeEntity goodsTypeEntity) {
        return goodsTypeService.addGoodsType(goodsTypeEntity);
    }
    @AuthIgnore
    @PostMapping("/update")
    public ResponseResult<Map<String, Object>> updateGoodsType(@RequestBody GoodsTypeEntity goodsTypeEntity) {
        return goodsTypeService.update(goodsTypeEntity);
    }
    @AuthIgnore
    @PostMapping("/delete")
    public ResponseResult<Map<String, Object>> deleteGoodsType(@RequestBody GoodsTypeEntity goodsTypeEntity) {

        return goodsTypeService.delete(goodsTypeEntity);}

}
